package com.huixuebao.api.controller.course;

import com.huixuebao.api.dto.CourseDTO;
import com.huixuebao.api.dto.PayAmountComplexResult;
import com.huixuebao.api.service.CourseService;
import com.huixuebao.common.bean.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * TODO
 *
 * @version 1.0
 * @date 2020-11-16 21:42
 */
@Slf4j
@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    CourseService courseService;

    /**
     *
     * @date 2020-11-17 21:28
     * @param cityId 城市编码Id
     * @param longitude 经度
     * @param latitude 纬度
     * @param distance 距离（单位米）
     * @return com.huixuebao.common.bean.ApiResult
     */
    @GetMapping("/byDistance")
    public ApiResult<List<CourseDTO>> getAllCourse(
            String cityId,
            Double longitude,
            Double latitude,
            Integer distance,
            Double minPrice,
            Double maxPrice,
            String categoryId,
            String brand,
            String courseName) {
        return courseService.getAllCourse(cityId, longitude, latitude, distance, minPrice, maxPrice, categoryId, brand, courseName);
    }

    /**
     *
     * @date 2020-11-17 23:28
     * @param courseNo 课程id
     * @return com.huixuebao.common.bean.ApiResult
     */
    @GetMapping("/getCoursePrice")
    public ApiResult<PayAmountComplexResult> getCoursePrice(@RequestParam String courseNo){

        return courseService.getCoursePrice(courseNo);
    }
}